package util;

import util.annotation.Cheated;
import util.annotation.Solved;
import util.annotation.Unsolved;

import java.util.logging.Logger;

/**
 *
 */
public class SolutionValidator {

    private static final Logger logger = Logger.getLogger(SolutionValidator.class.getName());

    /**
     * 检查输入的类有没有被解决
     * @param solutionClass 输入的 solution 类
     * @param <T> 类的类型
     */
    public static <T> void checkSolved(Class<T> solutionClass) {
        if (solutionClass.isAnnotationPresent(Unsolved.class)) {
            throw new RuntimeException("该问题还没有被解决！");
        }
        if (solutionClass.isAnnotationPresent(Cheated.class)) {
            logger.warning("尝试自己解决问题！");
            return;
        }
        if (!solutionClass.isAnnotationPresent(Solved.class)) {
            logger.warning("该类没有被标注已解决！");
        }
    }
}
